#################################
# top level Makefile for gm4lin #
#################################
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.

####### Compiler, tools and options
#general considerations
C_FLAGS=-O2 -W

#uncomment the following line in order to enable debug messages when running the software
#DEBUG= -g -Wall -DDEBUG

#comment the following lines to remove gettext support
#GETTEXT=-DGETTEXT
#LIB_GETTEXT=-lintl

#comment the following 5 lines to disable my_sql support
#MYSQL_LIBS= -lmysqlclient -lz
#MYSQL_CFG=/usr/bin/mysql_config
#MYSQL_LIBS=-L'/usr/lib/mysql' -lmysqlclient -lz -lcrypt -lnsl -lm
#MYSQL_INCLUDES=-I'/usr/include/mysql'
#SQL_DECLARE=-D SQL_LIBS

#for "buggy" implementations of sigaction
#BUGGY_SIGACTION=-DBUGGY_SIGACTION

#in order to use pselect() instead of select() (that is better)
PSELECT=-DPSELECT

#The "finline-function" option enables the compiler to replace the function call
# f(...) by the function body -> avoids saving/restoring processor context
#The "ffast-math" option  desables some checking of math lib
#it could suppress NaN output, so it has to be tested
#SIMPLE_PREC=-fshort-double
OPT_TEST=-fschedule-insns2 -fno-strict-aliasing
OPT_OK=-ffast-math -fomit-frame-pointer -finline-functions -fexpensive-optimizations
OPTIMISATIONS=$(OPT_OK) $(OPT_TEST)
#available architectures
INTEL_PENTIUM=-march=i586 -maccumulate-outgoing-args -DCPU=586 -malign-double #this is for pentium
ULTRA_SPARC=-mcpu=v8 -fdelayed-branch -m32 #-m64 #this is for Ultra Sparc
POWERPC_G4=-mcpu=powerpc -mtune=7400 -maltivec -mabi=altivec
ARM_XSCALE=-mcpu=xscale 

#select the architecture you are running
ARCHITECTURE=$(INTEL_PENTIUM)

#################################################################################
#You shoudln't have to change things below that line
#################################################################################
CC       = gcc
CFLAGS   = $(SQL_DECLARE) $(C_FLAGS) ${ARCHITECTURE} $(OPTIMISATIONS) $(DEBUG) ${BUGGY_SIGACTION} $(PSELECT) $(GETTEXT)
LINK     = gcc
INCPATH  = -I. -I/usr/include $(MYSQL_INCLUDES) 
LIBS     = -L/usr/X11R6/lib -lm $(MYSQL_LIBS) $(LIB_GETTEXT)
DEL_FILE = rm -f
DEL_DIR  = rmdir

####### Files

HEADERS = acquisition.h \
		constants.h \
		data_log.h \
		gm4lin.h \
		initializations.h \
		my_limits.h \
		probe.h \
		serial.h \
		structures.h
SOURCES = acquisition.c \
		data_log.c \
		gm4lin.c \
		initializations.c \
		probe.c \
		serial.c
OBJECTS = acquisition.o \
		data_log.o \
		gm4lin.o \
		initializations.o \
		probe.o \
		serial.o

TARGET   = gm4lin

first: all
####### Implicit rules

.SUFFIXES: .c .o

.c.o:
	$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<

####### Build rules

all: Makefile $(TARGET)

$(TARGET): $(OBJECTS)  
	$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(LIBS)

clean:
	-$(DEL_FILE) $(OBJECTS)
	-$(DEL_FILE) *~ core *.core


####### Sub-libraries

distclean: clean
	-$(DEL_FILE) $(TARGET) $(TARGET)


FORCE:

####### Compile

acquisition.o: acquisition.c acquisition.h \
		my_limits.h \
		structures.h \
		data_log.h \
		initializations.h \
		gm4lin.h \
		probe.h \
		serial.h
	$(CC) -c $(CFLAGS) $(INCPATH) -o acquisition.o acquisition.c

data_log.o: data_log.c data_log.h \
		initializations.h \
		structures.h \
		my_limits.h \
		gm4lin.h \
		probe.h \
		acquisition.h \
		serial.h
	$(CC) -c $(CFLAGS) $(INCPATH) -o data_log.o data_log.c

gm4lin.o: gm4lin.c gm4lin.h \
		my_limits.h \
		structures.h \
		probe.h \
		initializations.h \
		acquisition.h \
		data_log.h \
		serial.h
	$(CC) -c $(CFLAGS) $(INCPATH) -o gm4lin.o gm4lin.c

initializations.o: initializations.c initializations.h \
		structures.h \
		my_limits.h \
		gm4lin.h \
		probe.h \
		acquisition.h \
		data_log.h \
		serial.h
	$(CC) -c $(CFLAGS) $(INCPATH) -o initializations.o initializations.c

probe.o: probe.c probe.h \
		my_limits.h \
		serial.h \
		structures.h \
		gm4lin.h \
		initializations.h \
		acquisition.h \
		data_log.h
	$(CC) -c $(CFLAGS) $(INCPATH) -o probe.o probe.c

serial.o: serial.c gm4lin.h \
		my_limits.h \
		structures.h \
		probe.h \
		initializations.h \
		acquisition.h \
		data_log.h \
		serial.h
	$(CC) -c $(CFLAGS) $(INCPATH) -o serial.o serial.c

####### Install

install:  

uninstall:  

